home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c
- Subject: Re: Where Can I Find Standard C Library S
- Date: Fri, 09 Feb 1996 01:30:10 GMT
- Organization: Netcom
- Message-ID: <311aa327.89794367@nntp.ix.netcom.com>
- References: <4fb8mf$ouo@spanky.pls.ov.com> <4fb90l$ouo@spanky.pls.ov.com> <3119E6D9.60FD@cmt.lpr.mail.carel.fi>
- NNTP-Posting-Host: ix-dc19-08.ix.netcom.com
- X-NETCOM-Date: Thu Feb 08 5:29:49 PM PST 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- Ari Lukumies <aril@cmt.lpr.mail.carel.fi> wrote:
-
- > Fletcher.Glenn@ov.com wrote:
- > >
- > >
- > > Whoops! for strcpy:
- > >
- > > char *strcpy(char *destination, char *source)
- > > {
- > > char *retval;
- > >
- > > retval = destination;
- > > while((*destination++ = *source++) != '\0');
- > > return(retval);
- > > }
- > > Fletcher.Glenn@ov.com
- >
- > ... And you wonder why printf("%s\n", strcpy(tmp, "thingyam")); may not give correct
- > results using your strcpy version... Try this for size:
- >
- > char *strcpy(char *destination, char *source)
- > {
- > char *retval = destination;
- >
- > do
- > *destination = *source++;
- > while (*destination++ != '\0');
- > return retval;
- > }
- >
- > This will also copy the nul-terminator. :)
-
- Am I missing something here? What's wrong with Fletcher's code? Why
- the comment about the nul-terminator? Fletcher's code also copies it.
-
-
- Michael M Rubenstein
-